package com.fortune.rainshinecommon.alioss;

import com.fortune.rainshinecommon.base.AliOssParmsModel;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;


/**
 * @author wcy
 * @description 阿里OSS存储服务逻辑实现类
 * @createDate 2018/4/12
 * @updateBy
 * @updateDate
 */
@RestController
@RequestMapping("aliOss")
public class AliOssServiceImpl{


    /**
     * 文件上传服务逻辑实现
     * @param parm
     */
	@PostMapping("/uploadFile")
    public void uploadFile(@RequestBody AliOssParmsModel parm) throws IOException{
        String filePath = "shengxian/"+parm.getFolder()+"/"+parm.getFileName();
        String mkdir = "shengxian/"+parm.getFolder()+"/";
        OssUtils.uploadFile(mkdir,filePath,parm.getBytes());
    }

    /**
     * 获取url逻辑服务实现
     * @param fileName
     * @return
     */
	@PostMapping("/getUrl")
    public String getUrl(@RequestBody String fileName) {
        return OssUtils.getUrl(fileName);
    }
}
